Skip to content

ENH: New submodule for vtk_to_usd with correct colormap handling#23

Merged
aylward merged 3 commits intomainfrom
vtk_to_usd
Jan 30, 2026
Merged

ENH: New submodule for vtk_to_usd with correct colormap handling#23
aylward merged 3 commits intomainfrom
vtk_to_usd

Conversation

@aylward
Copy link
Copy Markdown
Collaborator

@aylward aylward commented Jan 30, 2026

Extensive changes to create a vtk_to_usd submodule. Leveraged examples from Omniverse and from Omniverse Connectors (e.g., the ParaView Connector) to adapt to the nuances of VTK and USD (e.g., no data array of higher than 4 dimensions, the period "." is not allowed in a primvar name but is often used in VTK data array names, etc). Also, improved handling of colormaps for the primvars.

Copilot AI review requested due to automatic review settings January 30, 2026 03:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a comprehensive new vtk_to_usd submodule for converting VTK files to USD format with improved colormap handling and data array preservation. The implementation is based on NVIDIA's ParaViewConnector architecture, adapted for file-based conversion without ParaView dependencies.

Changes:

  • Created new modular vtk_to_usd library with 7 core modules (data_structures, vtk_reader, usd_utils, material_manager, usd_mesh_converter, converter, init)
  • Removed old monolithic converters (ConvertVTKToUSDBase, ConvertVTKToUSDPolyMesh, ConvertVTKToUSDTetMesh)
  • Refactored ConvertVTKToUSD to use new library internally while maintaining high-level API
  • Added comprehensive test suite (430 lines)
  • Updated documentation and README files
  • Updated imports across experiments and workflows

Reviewed changes

Copilot reviewed 40 out of 41 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/physiomotion4d/vtk_to_usd/*.py New modular library implementation with data structures, readers, USD utils, materials, and converters
src/physiomotion4d/convert_vtk_to_usd.py Refactored to use vtk_to_usd library as backend
tests/test_vtk_to_usd_library.py Comprehensive test suite for new library
tests/test_convert_vtk_to_usd.py Updated tests for refactored converter
src/physiomotion4d/__init__.py Updated exports, removed old base classes
data/README.md Enhanced documentation with download status
Various notebooks Updated import statements

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +933 to +934
except Exception:
pass
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'except' clause does nothing but pass and there is no explanatory comment.

Suggested change
except Exception:
pass
except Exception as exc:
self.log_warning(
f"Failed to clear existing 'displayColor' time samples: {exc}"
)

Copilot uses AI. Check for mistakes.
elif self.settings.compute_normals:
logger.debug("Computing normals for mesh")
# Normals will be computed by renderer or in post-process
pass
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary 'pass' statement.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings January 30, 2026 12:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 46 out of 47 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


# Add time samples for subsequent steps
for mesh_data, time_code in zip(
mesh_data_sequence[1:], time_codes[1:], strict=False
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The strict=False parameter in zip() is only available in Python 3.10+. This will cause a TypeError in Python 3.9 and earlier. Consider either removing the strict parameter or checking that the lengths match before the loop, or update the minimum Python version requirement if Python 3.10+ is required.

Copilot uses AI. Check for mistakes.
Comment on lines +42 to +54
def __post_init__(self) -> None:
"""Validate data shape."""
if self.data.ndim == 1 and self.num_components == 1:
# Scalar array
pass
elif self.data.ndim == 2 and self.data.shape[1] == self.num_components:
# Vector/multi-component array
pass
else:
raise ValueError(
f"Data shape {self.data.shape} incompatible with "
f"num_components={self.num_components}"
)
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation in __post_init__ for GenericArray doesn't handle the case where num_components > 1 but data.ndim == 1. According to the code in usd_mesh_converter.py (lines 217-230), flat 1D arrays can be reshaped into 2D arrays with multiple components. The validation should allow 1D arrays when the length is divisible by num_components, or the reshaping logic in usd_mesh_converter.py should be moved here for consistency.

Copilot uses AI. Check for mistakes.
dc_attr = display_color_pv.GetAttr()
for t in list(dc_attr.GetTimeSamples()):
dc_attr.ClearAtTime(t)
except Exception:
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'except' clause does nothing but pass and there is no explanatory comment.

Copilot uses AI. Check for mistakes.
@aylward aylward merged commit 66b8fbe into main Jan 30, 2026
17 checks passed
@aylward aylward deleted the vtk_to_usd branch February 17, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants